' This program expands on the original AllGadgets program by making
'all the gadgets do something. This mainly entails connecting various
'gadgets so that they effect each other.
' For example, the listview gadget has been connected to the string gadget
'below it to allow you to change the entries in the listview, and the
'checkboxes now disable various other gadgets, but there are many other
'features, so have a play.
' This mainly demonstrates how easy it can be to set up an interesting
'program from a GadToolsBox framework. It also shows how to use the
'J Set Gadget Data command, along with the J Gadget Number/String commands
'(though for v39 upwards, it is more correct to use J Get Gadget Data).
' To help show how it was constructed, the changes made have been written
'below.
' Changes made:
'
' A handler has been added to interconnect the gadgets, this is in the
' wait loop. To do the actual processing, the _HANDLEGADGETS procedure has
' been added.
' The global variable _LISTSEL has been added to keep track of which item
' of the listview gadget has been selected.
' The size of the strings defined for the listview gadget in the _GUIDATA
' routine have been set to a standard length of 30. This is the same as the
' maximum string length for the attached string gadget. This allows us to
' edit the strings safely without the worry of writing out of the end of the
' string.
' The global variable MYASL has been added. Code for creating a file
' requester has been placed before the events loop, and a line to remove
' it in the cleanup routine
' The global variables DIS1-4 have been added to track which gadgets
' are disabled.
Global _SCRAPTAGS,SCRAPTAGS,_PORTLIST,_MESSLIST
Global PATH$,OSVER
Global FHEIGHT,FWIDTH,MBAR,OX,OY,SW,SH
Dim _GADGETSLABELS(1,9)
Global _GADGETSLABELS()
Dim _GADGETSSTRINGS(1)
Global _GADGETSSTRINGS()
Dim _GADGETSLISTS(1)
Global _GADGETSLISTS()
Dim _GADGETSGADS(19)
Global _GADGETSGADS()
Global _BUTTON1,_BUTTON2,_BUTTON3,_FILESTRING,_FILEGADGET,_CYCLE,_TEXT,_PALETTE,_SLIDER,_MX,_SCROLLER,_LISTVIEW,_LISTSTRING,_CBOX1,_CBOX2,_CBOX3,_CBOX4,_INTEGER,_NUMBER
Dim _GADGETSZOOM(1)
Global _GADGETSZOOM()
Global _GADGETSWIND
'** this is used to record the selected item in the listview
Global _LISTSEL
_LISTSEL=-1
'** this is used for the asl file requester
Global MYASL
'** these track whether certain gadgets are disabled
' DIS1 is the file gadget, DIS2 is the palette
' DIS3 is the number gadget, DIS4 is other 3 check boxes
Global DIS1,DIS2,DIS3,DIS4
On Error Proc _CLEANUP
_INITIALIZE
_GUIDATA
_SETUPALL
_SETPORTS
'** here we create the file requester, with a few appropriate tags.
'Note that this is done AFTER opening the window otherwise ASLFR_Window
'would be rather pointless.
'Remember to add a J Free Asl Requester line to the _CLEANUP routine
J Tag _SCRAPTAGS,1,Equ("ASLFR_TitleText"),J Make String("Select a file")
J Tag Equ("ASLFR_SleepWindow"),True
J Tag Equ("ASLFR_Window"),_GADGETSWIND
J Tag Equ("ASLFR_RejectIcons"),True
J Tag 0,0
MYASL=J Create Asl Requester(Equ("ASL_FileRequest"),_SCRAPTAGS)
Do
K=J Wait Message
While K
C=J Tag Data(_MESSLIST,1)
If C=Equ("IDCMP_CLOSEWINDOW")
_CLEANUP
Else If C=Equ("IDCMP_REFRESHWINDOW")
_DOREFRESH
Else If C=Equ("IDCMP_GADGETDOWN") or C=Equ("IDCMP_GADGETUP") or C=Equ("IDCMP_MOUSEMOVE")
_HANDLEGADGETS
End If
K=J Next Message
Wend
Loop
'** this procedure actually controls the gadgets. It's not as complex
' as it might at first seem
Procedure _HANDLEGADGETS
On Error Proc _CLEANUP
'these two connect the scroller to the mx gadget
If J Tag Data(_MESSLIST,4)=_GADGETSGADS(_SCROLLER)
J Tag SCRAPTAGS,1,Equ("GTMX_Active"),J Tag Data(_MESSLIST,2)
J Tag 0,0
J Set Gadget Data _GADGETSGADS(_MX),_GADGETSWIND,SCRAPTAGS
Else If J Tag Data(_MESSLIST,4)=_GADGETSGADS(_MX)
J Tag SCRAPTAGS,1,Equ("GTSC_Top"),J Tag Data(_MESSLIST,2)
J Tag 0,0
J Set Gadget Data _GADGETSGADS(_SCROLLER),_GADGETSWIND,SCRAPTAGS
'this connects the integer to the number gadget
Else If J Tag Data(_MESSLIST,4)=_GADGETSGADS(_INTEGER)
J Tag SCRAPTAGS,1,Equ("GTNM_Number"),J Gadget Number(_GADGETSGADS(_INTEGER))*20
J Tag 0,0
J Set Gadget Data _GADGETSGADS(_NUMBER),_GADGETSWIND,SCRAPTAGS
'these two connect the slider and the palette
Else If J Tag Data(_MESSLIST,4)=_GADGETSGADS(_PALETTE)
J Tag SCRAPTAGS,1,Equ("GTSL_Level"),J Tag Data(_MESSLIST,2)
J Tag 0,0
J Set Gadget Data _GADGETSGADS(_SLIDER),_GADGETSWIND,SCRAPTAGS
Else If J Tag Data(_MESSLIST,4)=_GADGETSGADS(_SLIDER)
J Tag SCRAPTAGS,1,Equ("GTPA_Color"),J Tag Data(_MESSLIST,2)
J Tag 0,0
J Set Gadget Data _GADGETSGADS(_PALETTE),_GADGETSWIND,SCRAPTAGS
'this connects the cycle to the text
Else If J Tag Data(_MESSLIST,4)=_GADGETSGADS(_CYCLE)
J Tag SCRAPTAGS,1,Equ("GTTX_Text"),_GADGETSLABELS(0,J Tag Data(_MESSLIST,2))
J Tag 0,0
J Set Gadget Data _GADGETSGADS(_TEXT),_GADGETSWIND,SCRAPTAGS
'this records which listview item is selected
Else If J Tag Data(_MESSLIST,4)=_GADGETSGADS(_LISTVIEW)
_LISTSEL=J Tag Data(_MESSLIST,2)
'this changes an item in the listview
Else If J Tag Data(_MESSLIST,4)=_GADGETSGADS(_LISTSTRING)